Example (Cont.)
wfunction lcm(a,b: integer): integer;
w(* Compute lcm of a, b  *)
wvar temp, prod: integer;
wbegin prod := a * b;
w if (a=0) or (b=0) then
w lcm := 0
w else   begin
w repeat
w                        temp := a mod b;
w     a := b;
w     b := temp
w                   until b = 0;
w                  lcm := prod div a;
w end
wend;
int lcm(int a, int b)
{
}
int temp, prod;
if
else {
}
(a == 0 || b == 0)
return prod / a;
b = temp;
a = b;
// Compute lcm of a,b
prod = a* b;
return 0;
do {
} while
temp = a % b;
(b != 0)
The lcm is product div gcd. We will compute gcd a different way here just for fun!